package com.yunzheng.studyLeaveSystem.modules.user.adjust.adjust.dao;

import com.yunzheng.studyLeaveSystem.modules.user.adjust.adjust.entity.Adjust;
import com.yunzheng.studyLeaveSystem.utils.DBUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: YunZheng
 * @Date: 2023/01/28/17:07
 * @Description:
 */
public class AdjustDao {
    /**
     * 添加调研学信息
     *
     * @param adjust
     * @throws SQLException
     */
    public void add(Adjust adjust,int id) throws Exception {
        Connection connection = DBUtils.getCon();
        String sql = "insert into adjust value(?,?,?,?,?,?,?,?,?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(8,id);
        preparedStatement.setString(1, adjust.getName());
        preparedStatement.setString(10, adjust.getGender());
        preparedStatement.setString(2, adjust.getTerm());
        preparedStatement.setString(3, adjust.getDirection());
        preparedStatement.setString(4, adjust.getLeave_date());
        preparedStatement.setString(5, adjust.getLeave_class());
        preparedStatement.setString(6, adjust.getAdjust_date());
        preparedStatement.setString(7, adjust.getAdjust_class());
        preparedStatement.setString(9, adjust.getReason());
        int rows = preparedStatement.executeUpdate();
        DBUtils.release(null, preparedStatement, connection);
    }
}
